{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-13T13:26:23.006010Z",
     "iopub.status.busy": "2023-11-13T13:26:23.005826Z",
     "iopub.status.idle": "2023-11-13T13:26:23.371763Z",
     "shell.execute_reply": "2023-11-13T13:26:23.371196Z",
     "shell.execute_reply.started": "2023-11-13T13:26:23.005988Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "\n",
    "stage = 'B'\n",
    "root = '../../../contest'\n",
    "\n",
    "df_train = pd.read_csv(os.path.join(root, 'train/GSLD_NATURE_CUST.csv'))\n",
    "df_test = pd.read_csv(os.path.join(root, '{}/GSLD_NATURE_CUST_{}.csv'.format(stage, stage)))\n",
    "\n",
    "save_path = '../data'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-13T13:26:23.373006Z",
     "iopub.status.busy": "2023-11-13T13:26:23.372806Z",
     "iopub.status.idle": "2023-11-13T13:26:23.378087Z",
     "shell.execute_reply": "2023-11-13T13:26:23.377416Z",
     "shell.execute_reply.started": "2023-11-13T13:26:23.372981Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "rank = {'A':0,'B':1,'C':2,'D':3,'E':4, 'F':5}\n",
    "sex = {'A':0,'B':1}\n",
    "def prepro(df):\n",
    "    del df['DATA_DAT']\n",
    "    del df['NTRL_SEAN_ACTV_IND'] # 没用\n",
    "    df['NTRL_CUST_SEX_CD'] = df['NTRL_CUST_SEX_CD'].map(sex)\n",
    "    df['NTRL_RANK_CD'] = df['NTRL_RANK_CD'].map(rank)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-13T13:26:23.379348Z",
     "iopub.status.busy": "2023-11-13T13:26:23.379174Z",
     "iopub.status.idle": "2023-11-13T13:26:23.398053Z",
     "shell.execute_reply": "2023-11-13T13:26:23.397589Z",
     "shell.execute_reply.started": "2023-11-13T13:26:23.379327Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_train = prepro(df_train)\n",
    "df_test = prepro(df_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-13T13:26:23.398987Z",
     "iopub.status.busy": "2023-11-13T13:26:23.398821Z",
     "iopub.status.idle": "2023-11-13T13:26:23.558099Z",
     "shell.execute_reply": "2023-11-13T13:26:23.557621Z",
     "shell.execute_reply.started": "2023-11-13T13:26:23.398967Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_train.to_csv(save_path+'/GSLD_NATURE_CUST.csv', index=False)\n",
    "df_test.to_csv(save_path+'/GSLD_NATURE_CUST_{}.csv'.format(stage), index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
